<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .box{
        width: 1000px;
        margin:  50px  auto;
    }
    table{
        width: 1000px;
        border-spacing: 0;
        border: 1px  solid rgba(7, 4, 4, 0.712);
    }
    tr{
        /* width: 100px; */
        height: 70px;
    }
    td{
        width: 150px;
        height: 70px;
        text-align: center;
        border: 1px solid gray;
    }
    input{
        width: 60px;
        text-align: center;

    }
    .checkbox-item,.checkbox-all{
        width: 50px;
    }
    img{
        width: 100px;
        height: 100px;
    }
    a{
        /* margin-left: 50px; */
       
        width: 100px;
        background-color: rgba(29, 14, 235, 0.349);
        font-size: larger;
        display: block;
        text-align: center;
        float: left;
        margin-left: 5px;
        margin-top: 5px;
    }
     .box2{
    float: right;
    }
    .minus, .plus{
        width: 20px;
        text-align: center;
    }
    .a,.del{
      font-size: 16px;
      text-decoration: none;
      background-color: rgba(0, 139, 139, 0.74);
      color: black;
      margin-left: 20px;
    }
</style>
<body>
    <div  class="box">
     <table></table>
 
    </div>
    <script src="../template-web.js"></script>
    <script src="../jquery/jquery-3.6.0.min.js"></script>

    <script  type="text/html"   id="user">
    <tr>
        <td>学生编号</td>
        <td>学生姓名</td>
        <td>学生头像</td>
        <td>学生年龄</td>
        <td>性别    </td>
        <td>操作    </td>
    </tr>

{{each list}}
    <tr>
        <td>{{$value.uid}}</td>
        <td>{{$value.username}}</td>
        <td><img src="{{$value.headerimg}}" alt=""></td>
        <td>{{$value.age}}</td>
        <td>{{$value.sex}}</td>
        <td><a href=""  onclick="del({{$value.uid}})"  >删除</a> </td>  
        <!-- 编辑器的问题 -->
    </tr>
    {{/each}}
    </script>
    <script>
   function show(){
      $.ajax({
        type:'get',
        url:'http://localhost:8088/api/list',
        data:{},
        success:function(list){
            let rus=list.resultInfo
            console.log(rus)
            show2(rus)
            return rus
        },error:function(err){
         console.log('错误'+err)
        }
    })
   }
   function  show2(list){
    let html=template('user',{list:list})
    document.querySelector('table').innerHTML=html
   }
   show()
//  show2()

function del(uid){
      $.ajax({
        type:'get',
        url:'http://localhost:8088/api/delete',
        data:{uid},
        success:function(list){

        },error:function(err){
         console.log('错误'+err)
        }
    })
   }
    </script>
</body>
</html>